package com.excel.service;

import java.util.List;

import com.excel.dao.StudentDao;
import com.excel.student.Student;

public class StudentServiceImpl implements StudentService {
	
	private StudentDao studentDao;
	private static StudentServiceImpl _instance = null;
	
	private StudentServiceImpl(){
		studentDao = new StudentDao();
	}
	
	//单例模式
	public static StudentServiceImpl getInstance(){
		if(_instance == null){
			_instance = new StudentServiceImpl();
		}
		return _instance;
	}
	
	@Override
	public void addStudent(Student student) {
		studentDao.addStudent(student);
	}

	@Override
	public void deleteStudent(int id) {
		studentDao.deleteStudent(id);
	}

	@Override
	public void updateStudent(Student student) {
		studentDao.updateStudent(student);
	}

	@Override
	public Student findById(int id) {
		return studentDao.findById(id);
	}

	@Override
	public List<Student> findAll() {
		return studentDao.findAll();
	}

}
